package com.xq.shop.controller.admin;

import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.xq.shop.po.CategoryParam;
import com.xq.shop.service.admin.IBaseService;
import com.xq.shop.service.admin.ICategoryParamService;
import com.xq.shop.util.AdminServiceFactory;
import com.xq.shop.vo.RespMsg;
import com.xq.shop.vo.SearchObject;
import com.xq.shop.vo.RespMsg.Result;

@Controller
@RequestMapping("/admin/")
public class CategoryParamController extends BaseController<CategoryParam> {

	private ICategoryParamService categoryParamService = AdminServiceFactory.getCategoryParamService();
	
	@Override
	public IBaseService<CategoryParam> getService() {
		return categoryParamService;
	}

	@RequestMapping("categoryParam_save.do")
	public ModelAndView save(CategoryParam param, HttpServletResponse response) throws Exception {
		
		categoryParamService.saveOrUpdate(param);
		ModelAndView modelAndView = new ModelAndView("admin/product/categoryParam_list");
		modelAndView.addObject(new RespMsg(Result.success, "保存成功"));
		return modelAndView;
	}

	@Override
	@RequestMapping("categoryParam_list.do")
	@ResponseBody
	public String list(SearchObject search) {
		return super.list(search);
	}
	
	@Override
	@RequestMapping("categoryParam_edit.do")
	public ModelAndView edit(String id, ModelAndView view) {
		return super.edit(id, new ModelAndView("admin/product/categoryParam_edit"));
	}
}